﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SHZY.BaseData.Entitys;
using SHZY.Business.Entitys;
using SHZY.Common.Enum;
using SHZY.DependencyInjection;
using SHZY.FriendlyException;
using SHZY.TaskScheduler;
using SqlSugar;
using SHZY.BaseData.Entitys.Entity;
using SHZY.Business.Interfaces;
using SHZY.Common.Extension;
using SHZY.Systems.Entitys.System;
using Aspose.Words.Lists;

namespace SHZY.Business.TimeTask
{
    public class BusinessTask : ISpareTimeWorker
    {
        /// <summary>
        /// 来料检验逾期计算.
        /// </summary>
        /// <param name="timer">参数</param>
        /// <param name="count">次数</param>
        [SpareTime("* * * * * ?", "来料检验逾期计算", ExecuteType = SpareTimeExecuteTypes.Serial)]
        public void GenerateInspectionOverdue(SpareTimer timer, long count)
        {
            //创建作用域
            Scoped.Create(async (factory, scope) =>
            {
                var sqlSugarRepository = App.GetService<IOverdueHandleService>(scope.ServiceProvider);
                await sqlSugarRepository.GenerateInspectionOverdue();

            });
        }

        /// <summary>
        /// 来料检验逾期计算.
        /// </summary>
        /// <param name="timer">参数</param>
        /// <param name="count">次数</param>
        [SpareTime("* * * * * ?", "制程检验逾期计算", ExecuteType = SpareTimeExecuteTypes.Serial)]
        public void GenerateIPQCInspectionOverdue(SpareTimer timer, long count)
        {
            //创建作用域
            Scoped.Create(async (factory, scope) =>
            {
                var sqlSugarRepository = App.GetService<IOverdueHandleService>(scope.ServiceProvider);
                await sqlSugarRepository.GenerateIPQCInspectionOverdue();

            });
        }
    }
}
